# 多阶段构建优化
# 使用 alpine 版本减小镜像大小
FROM node:22.17.0-alpine AS build
WORKDIR /app

# 优化依赖安装
COPY package*.json ./
# 设置环境变量禁用husky，然后安装依赖
ENV HUSKY=0
RUN npm ci

COPY . .
RUN npm run build

# 生产环境
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]